﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Xml.Linq;
using ExperimentUpon.Util;
using NHibernate;
using System.IO;

namespace ExperimentUpon.Web
{
    public class Global : System.Web.HttpApplication
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Global));

        protected void Application_Start(object sender, EventArgs e)
        {
            InitHibernateContext();
        }

        private void InitHibernateContext()
        {
            if (log.IsDebugEnabled) { 
                log.Debug("InitHibernateContext");
            }
            ISession session = null;
            try
            {
                session = NHibernateUtils.OpenSession();
            }
            catch (Exception e)
            {
                log.Error(e);
            }
            finally
            {
                if(session != null) session.Close();
            }
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}